{include file="common/header"}.
<style>
    #form-icon-preview {
        float: left;
        width: 34px;
        height: 36px;
        line-height: 36px;
        font-size: 30px!important;
        border: 1px solid #e6e6e6;
        text-align: center;
        border-radius: 3px;
    }
    .page-tips{
        margin-bottom: 20px;
    }
    .page-tips .layui-colla-title {
        height: 26px;
        line-height: 26px;
        background-color: #f9f9f9;
        color: #999;
    }
</style>
<div class="x-body">
    <div class="layui-collapse page-tips">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">温馨提示<i class="layui-icon layui-colla-icon"></i></h2>
            <div class="layui-colla-content layui-show">
                <p>系统菜单最高支持三级，列如: 用户管理->会员管理->会员列表</p>
            </div>
        </div>
    </div>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">所属菜单</label>
            <div class="layui-input-inline">
                <select name="parent_id" lay-verify="required">
                    <option value="0">顶级菜单</option>
                    {foreach $menu as $vo}
                    <option value="{$vo.id}">{:html_entity_decode($vo.str)}{$vo.title}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单名称</label>
            <div class="layui-input-inline">
                <input type="text" name="title" required  lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属控制器</label>
            <div class="layui-input-inline">
                <input type="text" name="controller" required  placeholder="请输入所属控制器" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">操作方法</label>
            <div class="layui-input-inline">
                <input type="text" name="methods" required  placeholder="请输入操作方法" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">显示到菜单</label>
            <div class="layui-input-inline">
                <input type="checkbox" name="is_nav" lay-skin="switch" lay-text="ON|OFF">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图标设置</label>
            <input type="hidden" class="layui-input field-icon" id="input-icon" name="icon" lay-verify="" autocomplete="off" placeholder="可自定义或使用系统图标">
            <i class="icon iconfont" id="form-icon-preview"></i>
            <a href="javascript:;" onclick="x_admin_show('选择图标','{:url("font")}')" title="选择图标" class="layui-btn layui-btn-primary j-iframe-pop fl">选择图标</a>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
</body>

</html>
<script>
layui.use(['form', 'laydate', 'upload','element'], function() {
    var $ = layui.jquery, laydate = layui.laydate, layer = layui.layer, upload = layui.upload,element = layui.element,form = layui.form;
    form.on('submit(formSubmit)', function(data){
        if (data.field.is_nav){
            data.field.is_nav = 1;
        } else{
            data.field.is_nav = 0;
        }
        var load = layer.load(1);
        $.post("{:url('add')}",data.field,function (res) {
            if (res.success){
                layer.msg(res.msg,{icon:1},function () {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.location.reload();
                })
            } else{
                layer.close(load);
                layer.msg(res.msg,{icon:2})
            }
        });
        return false;
    });
});
</script>
